<%--
  Created by IntelliJ IDEA.
  User: Roy
  Date: 2023/11/18
  Time: 23:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>吐槽吧管理员端</title>
</head>
<body>
    <h1>管理员列表</h1>
    <c:url var="prevUrl" value="/m/mList">
        <c:param name="currentPage" value="${currentPage - 1}" />
    </c:url>

    <c:url var="nextUrl" value="/m/mList">
        <c:param name="currentPage" value="${currentPage + 1}" />
    </c:url>
    <hr>
    <table border="1">
        <tr>
            <td>id</td>
            <td>username</td>
            <td>password</td>
            <td>full_name</td>
            <td>email</td>
            <td>phone_no</td>
            <td>delete</td>
            <td>是否删除</td>
        </tr>
        <c:forEach items="${managerList}" var="manager">
            <tr>
                <td>${manager.id}</td>
                <td>${manager.username}</td>
                <td>${manager.password}</td>
                <td>${manager.fullName}</td>
                <td>${manager.email}</td>
                <td>${manager.phoneNo}</td>
                <td>${manager.delete}</td>
                <%-- 如果是本人或者已删除，则不显示删除按钮 --%>
                <td>
                    <c:if test="${manager.delete == 0 && !(sessionScope.get('manager').getId() == manager.id)}">
                        <form action="/m/deleteManager" method="post">
                            <input type="hidden" name="managerId" value="${manager.id}" />
                            <button type="submit">删除</button>
                        </form>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
    </table>
    <hr>
    <c:if test="${!noLess}">
        <a href="${prevUrl}">上一页</a>
    </c:if>
    <c:if test="${!noMore}">
        <a href="${nextUrl}">下一页</a>
    </c:if>
    <hr>
    <a href="<c:url value="/mHome"/>">返回</a>
</body>
</html>
